#include "ShellLibrary.h"

void ParseCommandLine(char **args) {
    char *p;
    char *aux;
    register int i = 0, j;

    aux = malloc(CMDLINE_SIZE*sizeof(char));
    strcpy(aux, args[0]);
    p = strtok(aux, " ");
    while(p != NULL) {
        args[i++] = p;
        p = strtok(NULL, " ");
    }
    if(i > 0)
        args[i] = NULL;

    for (j = 0; j < i; j++)
        printf("args[%d] = %s\n", j, args[j]);
}

void VerifyCommand(char **args, short *id_cmd) {

    if(!strcmp(args[0], "exit")) {
        *id_cmd = -1;
    }
    else if(!strcmp(args[0], "cd")) {
        *id_cmd = 0;
    }
    else if(!strcmp(args[0], "mkdir")) {
        *id_cmd = 1;
    }
}

void ExecuteCommands(char **args, short id_cmd) {
    switch(id_cmd) {
        case 0:
            ChangeDirectory(args);
            break;
        case 1:
            CreateDirectory(args);
            break;


    }

}

